#include <cstdio>
#include <cstring>

const int N = 105, dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

int n, m, s, t, ans[N][N], T;

bool dfs(int step, int row, int col) {
  if (step > n * m) return true;
  for (int i = 0, tx, ty; i < 4; ++i) {
    tx = row + dx[i], ty = col + dy[i];
    if (tx > 0 && ty > 0 && tx <= n && ty <= m && !ans[tx][ty]) {
      ans[tx][ty] = step;
      if (dfs(step + 1, tx, ty)) return true;
      ans[tx][ty] = 0;
    }
  }
  return false;
}

int main() {
  freopen("grid.in", "r", stdin);
  freopen("grid.out", "w", stdout);

  scanf("%d", &T);
  while (T--) {
    scanf("%d%d%d%d", &n, &m, &s, &t);
//    avi = false;
    /*if (n == 1 && ((t != 1) && (t != m))) {
      puts("-1");
    }
    if (m == 1 && ((s != 1) && (s != n))) {
      puts("-1");
    }
    if () {
    }*/
    memset(ans, 0, sizeof(ans));
    ans[s][t] = 1;
    if (dfs(2, s, t)) {
      for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
          printf("%d ", ans[i][j]);
        }
        putchar('\n');
      }
    } else puts("-1");
  }
  return 0;
}
